package cn.edu.scau.cmi.front.dao;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.scau.cmi.ema.dao.AbstractJpaDao;
import cn.edu.scau.cmi.ema.domain.Event;
import cn.edu.scau.cmi.ema.domain.Foodbatch;
import cn.edu.scau.cmi.ema.domain.Standard;
import cn.edu.scau.cmi.ema.domain.base.CmiPagination;
import cn.edu.scau.cmi.ema.util.CmiSqlUtil;
import cn.edu.scau.cmi.front.domain.EventFoodbatch;

@Repository("CmiFeaturestandardDAO")
@Transactional
public class CmiFeaturestandardDAOImpl extends AbstractJpaDao implements CmiFeaturestandardDAO {

	@PersistenceContext(unitName = "ema")
	private EntityManager entityManager;
	
	@SuppressWarnings("unchecked")
	@Override
	public Set<Standard> findStandardsByFeatureId(int startResult, int maxRows,int featureId)throws DataAccessException {
		Query query = createNamedQuery("findStandardsByFeatureId", startResult,maxRows,featureId);
		return new LinkedHashSet<Standard>(query.getResultList());
	}

	@SuppressWarnings("unchecked")
	@Override
	public Set<Object> findFeaturesByStandardId(int startResult, int maxRows,int standardId)throws DataAccessException {
		Query query = createNamedQuery("findFeaturesByStandardId", startResult,maxRows,standardId);
		return new LinkedHashSet<Object>(query.getResultList());
	}
	
	

//	@Override
	public EntityManager getEntityManager() {
		// TODO Auto-generated method stub
		return entityManager;
	}

	@Override
	public boolean canBeMerged(Object o) {
		// TODO Auto-generated method stub
		return false;
	}



	@Override
	public Event executeQueryByNameSingleResult(String queryName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Event executeQueryByNameSingleResult(String queryName, Object... parameters) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Event executeQuerySingleResult(String queryString, Object... parameters) {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public Set getTypes() {
		// TODO Auto-generated method stub
		return null;
	}

}
